

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Mini-Language &mdash; Fityk 1.1.1 manual</title>
    <link rel="stylesheet" href="_static/fityk.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '1.1.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="shortcut icon" href="_static/fityk.ico"/>
    <link rel="top" title="Fityk 1.1.1 manual" href="index.html" />
    <link rel="next" title="Data" href="data.html" />
    <link rel="prev" title="Getting Started" href="getstarted.html" />
 


  </head>
  <body>
<div style="background-color: white; text-align: center; padding: 10px 10px 10px 10px">
 <a href="http://fityk.nieto.pl/"><img src="_static/fityk-banner.png" alt="" /></a>
</div>

      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
<h3><a href="fityk-manual.html">Table Of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="getstarted.html">Getting Started</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">Mini-Language</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#grammar">Grammar</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="data.html">Data</a></li>
<li class="toctree-l1"><a class="reference internal" href="model.html">Models</a></li>
<li class="toctree-l1"><a class="reference internal" href="fit.html">Curve Fitting</a></li>
<li class="toctree-l1"><a class="reference internal" href="ref.html">All the Rest</a></li>
</ul>

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/lang.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="mini-language">
<span id="lang"></span><h1>Mini-Language</h1>
<p>Fityk comes with own domain-specific language (DSL), which is humbly
called mini-language. All operations are driven by commands of the
mini-language.</p>
<div class="admonition-do-not-worry admonition ">
<p class="first admonition-title">Do not worry</p>
<p class="last">you do not need to learn the syntax of the mini-language.
It is possible to use menus and dialogs in the GUI
and avoid typing commands.</p>
</div>
<p>When you use the GUI and perform an action using the menu,
you can see the corresponding command in the output window.
It is one of less than 30 fityk commands. The commands have relatively
simple syntax and perform single actions, such as loading data from file,
adding function, assigning variable, fitting, or writing some values to a file.</p>
<p>It is possible to write a script (macro) as a sequence of such
commands. This can automate common tasks, although some complex tasks
still need to be programmed in a general-purpose language.
That is why Fityk comes with embedded Lua (lightweight programming language)
and also with bindings to Python and several other languages.</p>
<p>Now a quick glimps at the syntax. Here, the <tt class="docutils literal"><span class="pre">=-&gt;</span></tt> prompt marks an input:</p>
<div class="highlight-fityk"><div class="highlight"><pre><span class="gp">=-&gt; </span>print pi
3.14159
<span class="gp">=-&gt; </span><span class="c"># this is a comment -- from `#&#39; to the end of line</span>
<span class="gp">=-&gt; </span>p <span class="s1">&#39;2+3=&#39;</span>, 2+3 <span class="c"># p stands for print</span>
2+3 = 5
<span class="gp">=-&gt; </span>set numeric_format=<span class="s1">&#39;%.9f&#39;</span> <span class="c"># show 9 digits after dot</span>
<span class="gp">=-&gt; </span>pr pi, pi^2, pi^3 <span class="c"># pr, pri and prin also stand for print</span>
3.141592654 9.869604401 31.006276680
</pre></div>
</div>
<p>Usually, one line is one command, but if it is really needed,
two or more commands can be put in one line like this:</p>
<div class="highlight-fityk"><div class="highlight"><pre><span class="gp">=-&gt; </span>$a = 3; $b = 5 <span class="c"># two commands separated with `;&#39;</span>
</pre></div>
</div>
<p>If the user works simultaneously with multiple datasets, she can refer to
a dataset using its number: the first dataset is <tt class="docutils literal"><span class="pre">&#64;0</span></tt>, the second &#8211; <tt class="docutils literal"><span class="pre">&#64;1</span></tt>,
etc:</p>
<div class="highlight-fityk"><div class="highlight"><pre><span class="gp">=-&gt; </span>fit <span class="c"># perform fitting of the default dataset (the first one)</span>
<span class="gp">=-&gt; </span>@2: fit <span class="c"># fit the third dataset (@2)</span>
<span class="gp">=-&gt; </span>@*: fit <span class="c"># fit all datasets, one by one</span>
</pre></div>
</div>
<p>All settings in the program are changed using the command <tt class="docutils literal"><span class="pre">set</span></tt>:</p>
<div class="highlight-fityk"><div class="highlight"><pre>set key = value
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-fityk"><div class="highlight"><pre><span class="gp">=-&gt; </span>set logfile = <span class="s1">&#39;C:\log.fit&#39;</span> <span class="c"># log all commands to this file</span>
<span class="gp">=-&gt; </span>set verbosity = 1 <span class="c"># make output from the program more verbose</span>
<span class="gp">=-&gt; </span>set epsilon = 1e-14
</pre></div>
</div>
<p>The last example changes the <em>ε</em> value, which is used to test floating-point
numbers <em>a</em> and <em>b</em> for equality (it is well known that due to rounding
errors the equality test for two numbers should have some tolerance,
and the tolerance should be tailored to the application): |<em>a−b</em>| &lt; <em>ε</em>.</p>
<p>To change a setting only for one command, add <tt class="docutils literal"><span class="pre">with</span> <span class="pre">key=value</span></tt> before
the command:</p>
<div class="highlight-fityk"><div class="highlight"><pre><span class="gp">=-&gt; </span>with epsilon = 0.1 print pi == 3.14 <span class="c"># abusing epsilon</span>
1
<span class="gp">=-&gt; </span>print pi == 3.14 <span class="c"># default epsilon = 10^-12</span>
0
</pre></div>
</div>
<p>Writing informally, each line has a syntax:</p>
<div class="highlight-none"><div class="highlight"><pre>[[@...:] [with ...] command [&quot;;&quot; command]...] [#comment]
</pre></div>
</div>
<p>All the commands are described in the next chapters.</p>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p class="last">The rest of this section can be useful as reference, but it is recommended
to <strong>skip it</strong> when reading the manual for the first time.</p>
</div>
<p>To keep the description above concise, some details were skipped.</p>
<p>The datasets listed before the colon (<tt class="docutils literal"><span class="pre">:</span></tt>) make a <em>foreach</em> loop:</p>
<div class="highlight-none"><div class="highlight"><pre>=-&gt; $a=0
=-&gt; @0 @0 @0: $a={$a+1}; print $a
1
2
3
</pre></div>
</div>
<p><tt class="docutils literal"><span class="pre">&#64;*</span></tt> stands for all datasets, from <tt class="docutils literal"><span class="pre">&#64;0</span></tt> to the last one.</p>
<p>There is a small difference between two commands in two lines and two commands
separated by <tt class="docutils literal"><span class="pre">;</span></tt>.
The whole line is parsed before the execution begins and some checks
for the second command are performed before the first command is run:</p>
<div class="highlight-none"><div class="highlight"><pre>=-&gt; $a=4; print $a # print gives unexpected error
Error: undefined variable: $a

=-&gt; $b=2
=-&gt; $b=4; print $b # $b is already defined at the check time
4
</pre></div>
</div>
<div class="section" id="grammar">
<h2>Grammar</h2>
<p>The grammar is expressed in EBNF-like notation:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">(*this</span> <span class="pre">is</span> <span class="pre">a</span> <span class="pre">comment*)</span></tt></li>
<li><tt class="docutils literal"><span class="pre">A*</span></tt> means 0 or more occurrences of A.</li>
<li><tt class="docutils literal"><span class="pre">A+</span></tt> means 1 or more occurrences of A.</li>
<li><tt class="docutils literal"><span class="pre">A</span> <span class="pre">%</span> <span class="pre">B</span></tt> means <tt class="docutils literal"><span class="pre">A</span> <span class="pre">(B</span> <span class="pre">A)*</span></tt> and the <tt class="docutils literal"><span class="pre">%</span></tt> operator has the highest
precedence. For example: <tt class="docutils literal"><span class="pre">term</span> <span class="pre">%</span> <span class="pre">&quot;+&quot;</span> <span class="pre">comment</span></tt> is the same as
<tt class="docutils literal"><span class="pre">term</span> <span class="pre">(&quot;+&quot;</span> <span class="pre">term)*</span> <span class="pre">comment</span></tt>.</li>
<li>The colon &#8216;:&#8217; in quoted string means that the string can be shortened, e.g.
<tt class="docutils literal"><span class="pre">&quot;del:ete&quot;</span></tt> means that any of <tt class="docutils literal"><span class="pre">del</span></tt>, <tt class="docutils literal"><span class="pre">dele</span></tt>, <tt class="docutils literal"><span class="pre">delet</span></tt> and <tt class="docutils literal"><span class="pre">delete</span></tt>
can be used.</li>
</ul>
<p>The functions that can be used in <tt class="docutils literal"><span class="pre">p_expr</span></tt> and <tt class="docutils literal"><span class="pre">v_expr</span></tt> are available
<a class="reference internal" href="data.html#transform"><em>here</em></a> and <a class="reference internal" href="model.html#variables"><em>here</em></a>, respectively.
<tt class="docutils literal"><span class="pre">v_expr</span></tt> contains only a subset of functions from <tt class="docutils literal"><span class="pre">p_expr</span></tt> (partly,
because we need to calculate symbolical derivatives of <tt class="docutils literal"><span class="pre">v_expr</span></tt>)</p>
<p><strong>Line structure</strong></p>
<pre>
<strong id="grammar-token-line">line     </strong> ::=  [<a class="reference internal" href="#grammar-token-statement"><tt class="xref docutils literal"><span class="pre">statement</span></tt></a>] [<a class="reference internal" href="#grammar-token-comment"><tt class="xref docutils literal"><span class="pre">comment</span></tt></a>]
<strong id="grammar-token-statement">statement</strong> ::=  [Dataset+ &quot;:&quot;] [<a class="reference internal" href="#grammar-token-with_opts"><tt class="xref docutils literal"><span class="pre">with_opts</span></tt></a>] <a class="reference internal" href="#grammar-token-command"><tt class="xref docutils literal"><span class="pre">command</span></tt></a> % &quot;;&quot;
<strong id="grammar-token-with_opts">with_opts</strong> ::=  &quot;w:ith&quot; (Lname &quot;=&quot; <a class="reference internal" href="#grammar-token-value"><tt class="xref docutils literal"><span class="pre">value</span></tt></a>) % &quot;,&quot;
<strong id="grammar-token-comment">comment  </strong> ::=  &quot;#&quot; AllChars*
</pre>
<p><strong>Commands</strong></p>
<p>The kCmd* names in the comments correspond to constants in the code.</p>
<pre>
<strong id="grammar-token-command">command</strong> ::=  (
             &quot;deb:ug&quot; RestOfLine              | <em>(*kCmdDebug*)</em>
             &quot;def:ine&quot; <a class="reference internal" href="#grammar-token-define"><tt class="xref docutils literal"><span class="pre">define</span></tt></a>                 | <em>(*kCmdDefine*)</em>
             &quot;del:ete&quot; <a class="reference internal" href="#grammar-token-delete"><tt class="xref docutils literal"><span class="pre">delete</span></tt></a>                 | <em>(*kCmdDelete*)</em>
             &quot;del:ete&quot; <a class="reference internal" href="#grammar-token-delete_points"><tt class="xref docutils literal"><span class="pre">delete_points</span></tt></a>          | <em>(*kCmdDeleteP*)</em>
             &quot;e:xecute&quot; <a class="reference internal" href="#grammar-token-exec"><tt class="xref docutils literal"><span class="pre">exec</span></tt></a>                  | <em>(*kCmdExec*)</em>
             &quot;f:it&quot; <a class="reference internal" href="#grammar-token-fit"><tt class="xref docutils literal"><span class="pre">fit</span></tt></a>                       | <em>(*kCmdFit*)</em>
             &quot;g:uess&quot; <a class="reference internal" href="#grammar-token-guess"><tt class="xref docutils literal"><span class="pre">guess</span></tt></a>                   | <em>(*kCmdGuess*)</em>
             &quot;i:nfo&quot; <a class="reference internal" href="#grammar-token-info_arg"><tt class="xref docutils literal"><span class="pre">info_arg</span></tt></a> % &quot;,&quot; [<a class="reference internal" href="#grammar-token-redir"><tt class="xref docutils literal"><span class="pre">redir</span></tt></a>]   | <em>(*kCmdInfo*)</em>
             &quot;pl:ot&quot; [<a class="reference internal" href="#grammar-token-range"><tt class="xref docutils literal"><span class="pre">range</span></tt></a>] [<a class="reference internal" href="#grammar-token-range"><tt class="xref docutils literal"><span class="pre">range</span></tt></a>] Dataset* | <em>(*kCmdPlot*)</em>
             &quot;p:rint&quot; <a class="reference internal" href="#grammar-token-print_args"><tt class="xref docutils literal"><span class="pre">print_args</span></tt></a> [<a class="reference internal" href="#grammar-token-redir"><tt class="xref docutils literal"><span class="pre">redir</span></tt></a>]      | <em>(*kCmdPrint*)</em>
             &quot;quit&quot;                           | <em>(*kCmdQuit*)</em>
             &quot;reset&quot;                          | <em>(*kCmdReset*)</em>
             &quot;s:et&quot; (Lname &quot;=&quot; <a class="reference internal" href="#grammar-token-value"><tt class="xref docutils literal"><span class="pre">value</span></tt></a>) % &quot;,&quot;   | <em>(*kCmdSet*)</em>
             &quot;sleep&quot; <a class="reference internal" href="#grammar-token-expr"><tt class="xref docutils literal"><span class="pre">expr</span></tt></a>                     | <em>(*kCmdSleep*)</em>
             &quot;title&quot; &quot;=&quot; <a class="reference internal" href="#grammar-token-filename"><tt class="xref docutils literal"><span class="pre">filename</span></tt></a>             | <em>(*kCmdTitle*)</em>
             &quot;undef:ine&quot; Uname % &quot;,&quot;          | <em>(*kCmdUndef*)</em>
             &quot;use&quot; Dataset                    | <em>(*kCmdUse*)</em>
             &quot;!&quot; RestOfLine                   | <em>(*kCmdShell*)</em>
             Dataset &quot;&lt;&quot; <a class="reference internal" href="#grammar-token-load_arg"><tt class="xref docutils literal"><span class="pre">load_arg</span></tt></a>             | <em>(*kCmdLoad*)</em>
             Dataset &quot;=&quot; <tt class="xref docutils literal"><span class="pre">dataset_expr</span></tt>         | <em>(*kCmdDatasetTr*)</em>
             Funcname &quot;=&quot; <a class="reference internal" href="#grammar-token-func_rhs"><tt class="xref docutils literal"><span class="pre">func_rhs</span></tt></a>            | <em>(*kCmdNameFunc*)</em>
             <a class="reference internal" href="#grammar-token-param_lhs"><tt class="xref docutils literal"><span class="pre">param_lhs</span></tt></a> &quot;=&quot; <tt class="xref docutils literal"><span class="pre">v_expr</span></tt>             | <em>(*kCmdAssignParam*)</em>
             Varname &quot;=&quot; <tt class="xref docutils literal"><span class="pre">v_expr</span></tt>               | <em>(*kCmdNameVar*)</em>
             <a class="reference internal" href="#grammar-token-model_id"><tt class="xref docutils literal"><span class="pre">model_id</span></tt></a> (&quot;=&quot;|&quot;+=&quot;) <a class="reference internal" href="#grammar-token-model_rhs"><tt class="xref docutils literal"><span class="pre">model_rhs</span></tt></a>    | <em>(*kCmdChangeModel*)</em>
             (<a class="reference internal" href="#grammar-token-p_attr"><tt class="xref docutils literal"><span class="pre">p_attr</span></tt></a> &quot;[&quot; <a class="reference internal" href="#grammar-token-expr"><tt class="xref docutils literal"><span class="pre">expr</span></tt></a> &quot;]&quot; &quot;=&quot; <tt class="xref docutils literal"><span class="pre">p_expr</span></tt>) % &quot;,&quot; | <em>(*kCmdPointTr*)</em>
             (<a class="reference internal" href="#grammar-token-p_attr"><tt class="xref docutils literal"><span class="pre">p_attr</span></tt></a> &quot;=&quot; <tt class="xref docutils literal"><span class="pre">p_expr</span></tt>) % &quot;,&quot;        | <em>(*kCmdAllPointsTr*)</em>
             &quot;M&quot; &quot;=&quot; <a class="reference internal" href="#grammar-token-expr"><tt class="xref docutils literal"><span class="pre">expr</span></tt></a>                     ) <em>(*kCmdResizeP*)</em>
</pre>
<p><strong>Other rules</strong></p>
<pre>
<strong id="grammar-token-define">define        </strong> ::=  Uname &quot;(&quot; (Lname [ &quot;=&quot; <tt class="xref docutils literal"><span class="pre">v_expr</span></tt>]) % &quot;,&quot; &quot;)&quot; &quot;=&quot;
                       ( <tt class="xref docutils literal"><span class="pre">v_expr</span></tt> |
                         <a class="reference internal" href="#grammar-token-component_func"><tt class="xref docutils literal"><span class="pre">component_func</span></tt></a> % &quot;+&quot; |
                         &quot;x&quot; &quot;&lt;&quot; <tt class="xref docutils literal"><span class="pre">v_expr</span></tt> &quot;?&quot; <a class="reference internal" href="#grammar-token-component_func"><tt class="xref docutils literal"><span class="pre">component_func</span></tt></a> &quot;:&quot; <a class="reference internal" href="#grammar-token-component_func"><tt class="xref docutils literal"><span class="pre">component_func</span></tt></a>
                       )
<strong id="grammar-token-component_func">component_func</strong> ::=  Uname &quot;(&quot; <tt class="xref docutils literal"><span class="pre">v_expr</span></tt> % &quot;,&quot; &quot;)&quot;
<strong id="grammar-token-delete">delete        </strong> ::=  (Varname | <a class="reference internal" href="#grammar-token-func_id"><tt class="xref docutils literal"><span class="pre">func_id</span></tt></a> | Dataset | &quot;file&quot; <a class="reference internal" href="#grammar-token-filename"><tt class="xref docutils literal"><span class="pre">filename</span></tt></a>) % &quot;,&quot;
<strong id="grammar-token-delete_points">delete_points </strong> ::=  &quot;(&quot; <tt class="xref docutils literal"><span class="pre">p_expr</span></tt> &quot;)&quot;
<strong id="grammar-token-exec">exec          </strong> ::=  <a class="reference internal" href="#grammar-token-filename"><tt class="xref docutils literal"><span class="pre">filename</span></tt></a> |
                    &quot;!&quot; RestOfLine
<strong id="grammar-token-fit">fit           </strong> ::=  [Number] [Dataset*] |
                    &quot;+&quot; Number |
                    &quot;undo&quot; |
                    &quot;redo&quot; |
                    &quot;history&quot; Number |
                    &quot;clear_history&quot;
<strong id="grammar-token-guess">guess         </strong> ::=  [Funcname &quot;=&quot;] Uname [&quot;(&quot; (Lname &quot;=&quot; <tt class="xref docutils literal"><span class="pre">v_expr</span></tt>) % &quot;,&quot; &quot;)&quot;] [<a class="reference internal" href="#grammar-token-range"><tt class="xref docutils literal"><span class="pre">range</span></tt></a>]
<strong id="grammar-token-info_arg">info_arg      </strong> ::=  ...TODO
<strong id="grammar-token-print_args">print_args    </strong> ::=  [(&quot;all&quot; | (&quot;if&quot; <tt class="xref docutils literal"><span class="pre">p_expr</span></tt> &quot;:&quot;)]
                    (<tt class="xref docutils literal"><span class="pre">p_expr</span></tt> | QuotedString | &quot;title&quot; | &quot;filename&quot;) % &quot;,&quot;
<strong id="grammar-token-redir">redir         </strong> ::=  (&quot;&gt;&quot;|&quot;&gt;&gt;&quot;) <a class="reference internal" href="#grammar-token-filename"><tt class="xref docutils literal"><span class="pre">filename</span></tt></a>
<strong id="grammar-token-value">value         </strong> ::=  (Lname | QuotedString | <a class="reference internal" href="#grammar-token-expr"><tt class="xref docutils literal"><span class="pre">expr</span></tt></a>) <em>(*value type depends on the option*)</em>
<strong id="grammar-token-model_rhs">model_rhs     </strong> ::=  &quot;0&quot; |
                    <a class="reference internal" href="#grammar-token-func_id"><tt class="xref docutils literal"><span class="pre">func_id</span></tt></a> |
                    <a class="reference internal" href="#grammar-token-func_rhs"><tt class="xref docutils literal"><span class="pre">func_rhs</span></tt></a> |
                    <a class="reference internal" href="#grammar-token-model_id"><tt class="xref docutils literal"><span class="pre">model_id</span></tt></a> |
                    &quot;copy&quot; &quot;(&quot; <a class="reference internal" href="#grammar-token-model_id"><tt class="xref docutils literal"><span class="pre">model_id</span></tt></a> &quot;)&quot;
<strong id="grammar-token-func_rhs">func_rhs      </strong> ::=  Uname &quot;(&quot; ([Lname &quot;=&quot;] <tt class="xref docutils literal"><span class="pre">v_expr</span></tt>) % &quot;,&quot; &quot;)&quot; |
                    &quot;copy&quot; &quot;(&quot; <a class="reference internal" href="#grammar-token-func_id"><tt class="xref docutils literal"><span class="pre">func_id</span></tt></a> &quot;)&quot;
<strong id="grammar-token-load_arg">load_arg      </strong> ::=  <a class="reference internal" href="#grammar-token-filename"><tt class="xref docutils literal"><span class="pre">filename</span></tt></a> Lname* |
                    &quot;.&quot;
<strong id="grammar-token-p_attr">p_attr        </strong> ::=  (&quot;X&quot; | &quot;Y&quot; | &quot;S&quot; | &quot;A&quot;)
<strong id="grammar-token-model_id">model_id      </strong> ::=  [Dataset &quot;.&quot;] (&quot;F&quot;|&quot;Z&quot;)
<strong id="grammar-token-func_id">func_id       </strong> ::=  Funcname |
                    <a class="reference internal" href="#grammar-token-model_id"><tt class="xref docutils literal"><span class="pre">model_id</span></tt></a> &quot;[&quot; Number &quot;]&quot;
<strong id="grammar-token-param_lhs">param_lhs     </strong> ::=  Funcname &quot;.&quot; Lname |
                    <a class="reference internal" href="#grammar-token-model_id"><tt class="xref docutils literal"><span class="pre">model_id</span></tt></a> &quot;[&quot; (Number | &quot;*&quot;) &quot;]&quot; &quot;.&quot; Lname
<strong id="grammar-token-var_id">var_id        </strong> ::=  Varname |
                    <a class="reference internal" href="#grammar-token-func_id"><tt class="xref docutils literal"><span class="pre">func_id</span></tt></a> &quot;.&quot; Lname
<strong id="grammar-token-range">range         </strong> ::=  &quot;[&quot; [<a class="reference internal" href="#grammar-token-expr"><tt class="xref docutils literal"><span class="pre">expr</span></tt></a>] &quot;:&quot; [<a class="reference internal" href="#grammar-token-expr"><tt class="xref docutils literal"><span class="pre">expr</span></tt></a>] &quot;]&quot;
<strong id="grammar-token-filename">filename      </strong> ::=  QuotedString | NonblankString
</pre>
<p><strong>Mathematical expressions</strong></p>
<pre>
<strong id="grammar-token-expr">expr       </strong> ::=  expr_or ? expr_or : expr_or
<strong id="grammar-token-expr_or">expr_or    </strong> ::=  expr_and % &quot;or&quot;
<strong id="grammar-token-expr_and">expr_and   </strong> ::=  expr_not % &quot;and&quot;
<strong id="grammar-token-expr_not">expr_not   </strong> ::=  &quot;not&quot; expr_not | comparison
<strong id="grammar-token-comparison">comparison </strong> ::=  arith % (&quot;&lt;&quot;|&quot;&gt;&quot;|&quot;==&quot;|&quot;&gt;=&quot;|&quot;&lt;=&quot;|&quot;!=&quot;)
<strong id="grammar-token-arith">arith      </strong> ::=  term % (&quot;+&quot;|&quot;-&quot;)
<strong id="grammar-token-term">term       </strong> ::=  factor % (&quot;*&quot;|&quot;/&quot;)
<strong id="grammar-token-factor">factor     </strong> ::=  ('+'|'-') factor | power
<strong id="grammar-token-power">power      </strong> ::=  atom ['**' factor]
<strong id="grammar-token-atom">atom       </strong> ::=  Number | &quot;true&quot; | &quot;false&quot; | &quot;pi&quot; |
                 math_func | braced_expr | ?others?
<strong id="grammar-token-math_func">math_func  </strong> ::=  &quot;sqrt&quot; &quot;(&quot; expr &quot;)&quot; |
                 &quot;gamma&quot; &quot;(&quot; expr &quot;)&quot; |
                  ...
<strong id="grammar-token-braced_expr">braced_expr</strong> ::=  &quot;{&quot; [Dataset+ &quot;:&quot;] <tt class="xref docutils literal"><span class="pre">p_expr</span></tt> &quot;}&quot;
</pre>
<p>The <tt class="docutils literal"><span class="pre">atom</span></tt> rule also accepts some fityk expressions, such as $variable,
%function.parameter, %function(expr), etc.</p>
<p><tt class="docutils literal"><span class="pre">p_expr</span></tt> and <tt class="docutils literal"><span class="pre">v_expr</span></tt> are similar to <tt class="docutils literal"><span class="pre">expr</span></tt>,
but they use additional variables in the <tt class="docutils literal"><span class="pre">atom</span></tt> rule.</p>
<p><tt class="docutils literal"><span class="pre">p_expr</span></tt> recognizes <tt class="docutils literal"><span class="pre">n</span></tt>, <tt class="docutils literal"><span class="pre">M</span></tt>, <tt class="docutils literal"><span class="pre">x</span></tt>, <tt class="docutils literal"><span class="pre">y</span></tt>, <tt class="docutils literal"><span class="pre">s</span></tt>, <tt class="docutils literal"><span class="pre">a</span></tt>, <tt class="docutils literal"><span class="pre">X</span></tt>, <tt class="docutils literal"><span class="pre">Y</span></tt>,
<tt class="docutils literal"><span class="pre">S</span></tt> and <tt class="docutils literal"><span class="pre">A</span></tt>. All of them but <tt class="docutils literal"><span class="pre">n</span></tt> and <tt class="docutils literal"><span class="pre">M</span></tt> can be indexed
(e.g.  <tt class="docutils literal"><span class="pre">x[4]</span></tt>).  Example: <tt class="docutils literal"><span class="pre">(x+x[n-1])/2</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">v_expr</span></tt> uses all unknown names (<tt class="docutils literal"><span class="pre">Lname</span></tt>) as variables. The tilde (<tt class="docutils literal"><span class="pre">~</span></tt>)
can be used to create simple-variables.
Only a subset of functions (<tt class="docutils literal"><span class="pre">math_func</span></tt>) from <tt class="docutils literal"><span class="pre">expr</span></tt> is supported.
Examples: <tt class="docutils literal"><span class="pre">a+b*x^2</span></tt>, <tt class="docutils literal"><span class="pre">~5</span></tt>.</p>
<p>Since <tt class="docutils literal"><span class="pre">v_expr</span></tt> is used to define variables and user-defined functions,
the program calculates symbolically derivatives of <tt class="docutils literal"><span class="pre">v_expr</span></tt>.
That is why not all the function from <tt class="docutils literal"><span class="pre">expr</span></tt> are supported
(they may be added in the future).</p>
<p><tt class="docutils literal"><span class="pre">dataset_expr</span></tt> supports very limited set of operators and a few functions
that take Dataset token as argument (example: <tt class="docutils literal"><span class="pre">&#64;0</span> <span class="pre">-</span> <span class="pre">shirley_bg(&#64;0)</span></tt>).</p>
<p><strong>Lexer</strong></p>
<p>Below, some of the tokens produced by the fityk lexer are defined.</p>
<p>The lexer is context-dependend: <tt class="docutils literal"><span class="pre">NonblankString</span></tt> and <tt class="docutils literal"><span class="pre">RestOfLine</span></tt>
are produced only when they are expected in the grammar.</p>
<p><tt class="docutils literal"><span class="pre">Uname</span></tt> is used only for function types (Gaussian)
and pseudo-parameters (%f.Area).</p>
<pre>
<strong id="grammar-token-Dataset">Dataset       </strong> ::=  &quot;&#64;&quot;(Digit+|&quot;+&quot;|&quot;*&quot;)
<strong id="grammar-token-Varname">Varname       </strong> ::=  &quot;$&quot; Lname
<strong id="grammar-token-Funcname">Funcname      </strong> ::=  &quot;%&quot; Lname
<strong id="grammar-token-QuotedString">QuotedString  </strong> ::=  &quot;'&quot; (AllChars - &quot;'&quot;)* &quot;'&quot;
<strong id="grammar-token-Lname">Lname         </strong> ::=  (LowerCase | &quot;_&quot;) (LowerCase | Digit | &quot;_&quot;)*
<strong id="grammar-token-Uname">Uname         </strong> ::=  UpperCase AlphaNum+
<strong id="grammar-token-Number">Number        </strong> ::=  ?number read by strtod()?
<strong id="grammar-token-NonblankString">NonblankString</strong> ::=  (AllChars - (WhiteSpace | &quot;;&quot; | &quot;#&quot; ))*
<strong id="grammar-token-RestOfLine">RestOfLine    </strong> ::=  AllChars*
</pre>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="data.html" title="Data"
             accesskey="N">next</a></li>
        <li class="right" >
          <a href="getstarted.html" title="Getting Started"
             accesskey="P">previous</a> &nbsp; </li>
  <li><a href="http://fityk.nieto.pl/">Home</a>&nbsp;&nbsp;&nbsp;</li>
  <li><a href="https://github.com/wojdyr/fityk/wiki">Wiki</a>&nbsp;&nbsp;&nbsp;</li>
  
        <li><a href="fityk-manual.html">Manual</a> </li>
 
      </ul>
    </div>
    <div class="footer">
      Last updated on 2011-09-28.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
    </div>
  </body>
</html>